package itcz.example.pattern.structure_type.adapter.object_adapter;

/**
 * @ClassName: Client
 * @Author: ITCZ
 * @Date: 2025-04-23
 * @Description: 对象适配器模式
 * 符合合成复用原则
 * JDK 中的适配器模式
 * Reader(字符流)、InputStream(字节流) 的适配使用的是 InputStreamReader(字节流到字符流的转换)
 */
public class Client {
    public static void main(String[] args) {
        Computer computer = new Computer();
        String msg1 = computer.readSD(new SDCardImpl());
        System.out.println(msg1);

        System.out.println("====================");
        // 使用该电脑读取TF卡的数据
        // 创建适配器类对象
        SDAdapterTF sdAdapterTF = new SDAdapterTF(new TFCardImpl());
        String msg2 = computer.readSD(sdAdapterTF);
        System.out.println(msg2);
    }
}
